package tk.deep.bh2.dao.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.deep.bh2.dao.domain.Child;
import tk.deep.bh2.dao.domain.Parent;

import java.util.List;


public interface Mapper {

    //if @Select is used table/column name and class/property name should be the same
    //SQL query in "Mapper.xml"
    List<Parent> selectAllParent();

    //SQL query in "Mapper.xml"
    Parent selectParent(@Param("id") int id);

    @Insert("INSERT INTO parent (parentName) VALUES (#{parentName})")
    int insertParent(Parent parent);

    @Select("SELECT * FROM child WHERE parentId = #{id}")
    List<Child> selectAllChildren(@Param("id") int id);

    @Select("SELECT * FROM child WHERE childId = #{id}")
    Child selectChild(@Param("id") int id);

    //SQL query in "Mapper.xml"
    int insertchild(Child child);

}